<template>
  <div class="pages_content table dataPlan">
    <el-container>
      <el-main style="display: flex">
        <div>
          <div class="header_right" @click="showCardNav = !showCardNav">
            <div class="title">搜索</div>
            <div>
              <transition name="from"></transition>
              <span v-show="!showCardNav">
                <i style="margin-right: 5px" class="el-icon-arrow-down"></i>
              </span>
              <transition name="to"></transition>
              <span v-show="showCardNav">
                <i style="margin-right: 5px" class="el-icon-arrow-up"></i>
              </span>
            </div>
          </div>
          <div v-show="showCardNav" class="hr"></div>
          <el-collapse-transition>
            <div v-show="showCardNav">
              <div class="search">
                <span style="margin-left: 24px">
                  <span style="margin-right: 12px">浇筑部位</span>
                  <el-input v-model="tableParam.structuralParts" style="width: 240px" clearable placeholder="请输入" @keyup.enter.native="gettableData()" />
                </span>
                <el-button icon="el-icon-search" size="medium" class="bottom_all" @click="(tableParam.page = 1), gettableData()">查 询</el-button>
                <el-button size="medium" class="bottom_all_two" style="margin-left: 12px" @click="init()">重 置</el-button>
              </div>
            </div>
          </el-collapse-transition>
          <div class="hr"></div>
          <div class="card">
            <div class="card_nav">
              <div>
                <el-button size="small" class="bottom_three" @click="addDialogFun('添加')">
                  添加交工订单
                </el-button>
                <el-button size="small" class="bottom_three" @click="planQuerySignOfPageFun()">
                  添加客户订单
                </el-button>
                <el-button size="small" class="bottom_three" :disabled="tableDataSelect.length==0" @click="handOverPlandeleteResordFun()">
                  删除订单
                </el-button>
                <el-button size="small" class="bottom_three" @click="look4Fun()">
                  强度合格评定
                </el-button>
              </div>
              <div>
                <el-dropdown :hide-on-click="false" trigger="click" style="margin: 0 20px">
                  <el-link :underline="false">
                    <span class="el-icon--left">
                      <i class="iconfont iconicon_button_filtrate"></i>
                    </span>
                    筛选
                  </el-link>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item v-for="(item, index) in table" :key="index">
                      <el-checkbox v-model="item.status">{{
                        item.label
                        }}</el-checkbox>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </div>
            </div>
            <div v-loading="tableLoading" class="card_info" :style="style">
              <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="tableData" tooltip-effect="dark" @selection-change="list1SelectionFun">
                <el-table-column type="selection" width="55" fixed>
                </el-table-column>
                <template v-for="(item, index2) in table">
                  <el-table-column v-if="item.status" :key="index2" :label="item.label" align="center" :width="item.width">
                    <template slot-scope="scope">
                      <span v-if="item.label == '产品名'">
                        <span v-if="scope.row.productDeployStatus == 1" class="table_link" style="color:red;" @click="$refs.ProduceCoordinate.look1Fun(scope.row)">{{scope.row.productName}}(待配置)</span>
                        <span v-else class="table_link" @click="$refs.ProduceCoordinate.look1Fun(scope.row)">{{scope.row.productName}}(已配置)</span>
                      </span>
                      <span v-else-if="item.label == '配合比'">
                        <span v-if="scope.row.mixRatioDeployStatus == 1" class="table_link" style="color:red;" @click="$refs.ProduceCoordinate.look2Fun(scope.row,false)">待配置</span>
                        <span v-else class="table_link" @click="$refs.ProduceCoordinate.look2Fun(scope.row,true)">已配置</span>
                      </span>
                      <span v-else-if="item.label == '类型'">
                        <span v-if="scope.row.orderType == 1">客户订单</span>
                        <span v-if="scope.row.orderType == 2">交工订单</span>
                      </span>
                      <span v-else-if="item.label == '操作'">
                        <el-button style="margin:5px 0" class="bottom_one" size="mini" @click="addDialogFun('修改',scope.row)">
                          修改
                        </el-button>
                      </span>
                      <span v-else>{{ scope.row[item.prop] }}</span>
                    </template>
                  </el-table-column>
                </template>
              </el-table>
            </div>
            <div class="card_bottom">
              <div class="card_bottom_left">
                <div class="top_page_totle">总共{{ total }}条</div>
                <el-pagination :current-page.sync="tableParam.page" :page-size="tableParam.pageSize" layout="prev, pager, next, jumper" :total="total" @current-change="gettableData()"></el-pagination>
              </div>
              <div>
                <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="gettableData">刷新</el-button>
              </div>
            </div>
          </div>
        </div>
      </el-main>
    </el-container>
    <ProduceCoordinate ref="ProduceCoordinate" :status="2" @gettableData0="gettableData"></ProduceCoordinate>
    <!-- 添加 -->
    <el-dialog v-dialogDrag :visible.sync="addDialog" width="1000px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">{{look1Name}}</span>
      <div class="dialoginfo">
        <el-form ref="reffromData" :rules="rules" :inline="true" :model="formData" label-width="110px">
          <el-form-item prop="stationId" :rules="[{required: true,message: '请选择站点名称',trigger: 'change',}]">
            <span slot="label">站点名称</span>
            <el-select ref="selection2" v-model="formData.stationId" placeholder="请选择" @change="get_simple_organizationFun(formData.stationId),$nextTick(()=>{formData.stationName = $refs.selection2.selectedLabel})">
              <el-option v-for="item in stationIdlist" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="structuralParts">
            <span slot="label">浇筑部位</span>
            <el-select v-model="formData.structuralParts" filterable allow-create default-first-option placeholder="请选择" @change="structuralPartsCheckFun()">
              <el-option v-for="item in structuralPartsList" :key="item.id" :label="item.structuralParts" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="strengthGradeId" label="强度等级">
            <el-select v-model="formData.strengthGradeId" placeholder="请选择">
              <el-option v-for="item in strengthGradeList" :key="item.ID" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <span slot="label">性能等级</span>
            <el-select v-model="formData.performanceGradeId" multiple placeholder="请选择">
              <el-option v-for="item in performanceGradeList" :key="item.ID" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <span slot="label">材料要求</span>
            <el-select v-model="formData.meterialRequirementsId" multiple placeholder="请选择">
              <el-option v-for="item in meterialRequirementsList" :key="item.ID" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <span slot="label">特殊要求</span>
            <el-select v-model="formData.specialRequirementsId" multiple placeholder="请选择">
              <el-option v-for="item in specialRequirementsList" :key="item.ID" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <span slot="label">其他要求</span>
            <el-select v-model="formData.otherRequirementsId" multiple placeholder="请选择">
              <el-option v-for="item in otherRequirementsList" :key="item.ID" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <span slot="label">外加剂要求</span>
            <el-select v-model="formData.admixtureRequirements" multiple placeholder="请选择">
              <el-option v-for="item in admixtureRequirementsList" :key="item.ID" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="pouringMethod">
            <span slot="label">浇筑方式</span>
            <el-select v-model="formData.pouringMethod" multiple placeholder="请选择">
              <el-option v-for="item in pouringMethodList" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="pouringTime">
            <span slot="label">浇筑时间</span>
            <el-date-picker v-model="formData.pouringTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择"></el-date-picker>
          </el-form-item>
          <el-form-item prop="pouringNum">
            <span slot="label">浇筑用量(方)</span>
            <el-input v-model="formData.pouringNum" placeholder="请输入" type="Number"></el-input>
          </el-form-item>
          <el-form-item prop="pouringHigh">
            <span slot="label">泵送高度(米)</span>
            <el-input v-model="formData.pouringHigh" placeholder="请输入" type="Number"></el-input>
          </el-form-item>
          <el-form-item prop="person">
            <span slot="label">联系人</span>
            <el-input v-model="formData.person" placeholder="请输入"></el-input>
          </el-form-item>
          <el-form-item prop="phoneNum">
            <span slot="label">联系电话</span>
            <el-input v-model="formData.phoneNum" type="Number" placeholder="请输入"></el-input>
          </el-form-item>
          <el-form-item prop="structureSize">
            <span slot="label">订单备注</span>
            <el-input v-model="formData.remark" :rows="5" resize="none" style="width: 760px;" type="textarea" placeholder="请输入" clearable></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="addDialog =false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="submit()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 添加客户订单列表 -->
    <el-dialog v-dialogDrag :visible.sync="look2Type" width="880px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">添加客户订单</span>
      <div class="dialogOtherinfo">
        <el-table ref="table11Refs" height="300" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="QuerySignOfPageArr" tooltip-effect="dark" highlight-current-row @selection-change="selectionChange2">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column prop="orderNo" label="订单编号" width="auto" align="center"></el-table-column>
          <el-table-column prop="engineeringName" label="工程名称" width="auto" align="center"></el-table-column>
          <el-table-column prop="place" label="工程地质" width="auto" align="center"></el-table-column>
          <el-table-column prop="structuralParts" label="浇筑部位" width="auto" align="center"></el-table-column>
          <el-table-column prop="productName" label="产品名" width="160" align="center"></el-table-column>
          <el-table-column prop="" label="配合比" width="auto" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.mixRatioDeployStatus == 1" class="table_link" style="color:red;cursor:default;">待配置</span>
              <span v-else class="table_link" style="cursor:default;">已配置</span>
            </template>
          </el-table-column>
          <el-table-column prop="mixRatioNumber" label="交工配合比编号" width="auto" align="center"></el-table-column>
          <el-table-column prop="reportTime" label="报告时间" width="auto" align="center"></el-table-column>
          <el-table-column prop="pouringTime" label="浇筑时间" width="auto" align="center"></el-table-column>
          <el-table-column prop="" label="状态" width="120" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.handOverStatus == 1" style="color: #969799">未交工</span>
              <span v-if="scope.row.handOverStatus == 2" style="color: #00a754">已交工</span>
            </template>
          </el-table-column>
        </el-table>
        <div class="card_bottom">
          <div class="card_bottom_left">
            <div class="top_page_totle">总共{{ planQuerySignOfPageData.total }}条</div>
            <el-pagination :current-page.sync="planQuerySignOfPageData.page" :page-size="planQuerySignOfPageData.pageSize" layout="prev, pager, next, jumper" :total="planQuerySignOfPageData.total" @current-change="planQuerySignOfPageFun()"></el-pagination>
          </div>
          <div>
            <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="planQuerySignOfPageFun">刷新</el-button>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="look2Type = false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="handOverPlansaveClientOrderFun()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 强度合格评定 -->
    <el-dialog v-dialogDrag :visible.sync="look4Type" width="880px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">强度合格评定</span>
      <div class="dialogOtherinfo">
        <div v-for="(item,k) in look4Data" :key="k" class="FzyBox">
          <div>
            <div>设计强度：</div>
            <div>{{item.strengthGrade}}</div>
          </div>
          <div>
            <div>试件组数：</div>
            <div>{{item.count}}</div>
          </div>
          <div>
            <div>验收批各组试件强度：</div>
            <div>
              <el-link v-for="(v,k2) in item.selfReporVos" :key="k2" class="table_link" :underline="false" @click="look5Fun(v.projectList,v.centralValue)">{{v.centralValue}}；</el-link>
            </div>
          </div>
          <div>
            <div>标准差未知统计方法：</div>
            <div>
              <span v-for="(v,k2) in item.parameterMap" :key="k2">{{v}}</span>
            </div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="look4Type = false">关 闭</el-button>
      </span>
    </el-dialog>
    <!-- 强度合格评定 -->
    <el-dialog v-dialogDrag :visible.sync="look5Type" width="880px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">强度合格评定</span>
      <div class="dialogOtherinfo">
        <div class="FzyBox2">
          <div>
            <div>
              破坏荷载（KN）：
            </div>
            <div>
              单块值：
            </div>
            <div>
              代表值：
            </div>
          </div>
          <div>
            <div v-for="(item,k) in look5Data" :key="k" class="box1">
              <div>
                <!-- <el-input v-model="item.loadValue" style="width:100%;" type="Number"></el-input> -->
                <el-input v-model="item.resultValue" style="width:100%;" type="Number"></el-input>
              </div>
              <div>
                <div>{{item.singleBlockValue?item.singleBlockValue:''}}</div>
              </div>
              <div>
                <div>{{item.centralValue?item.centralValue:''}}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="look5Type = false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="submit5Fun()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import mixin from "@/mixins/ICPSmixin.js";
import {
  queryPage,
  Download,
  handOverPlansaveOrUpdate,
  planQuerySignOfPage,
  handOverPlansaveClientOrder,
  handOverPlandeleteResord,
  handOverPlanstrength_assessment,
  update_strength_assessment,
} from "@/api/smart/components_data/dataPlan.js";
import produceCoordinate from "./produce_coordinate"//引入产品名和配合比的内容组件
import { graphic_list } from "@/api/smart/schedul/b.js";
import { getUserInfo } from "@/utils/auth.js";
import { getStationByCompanyId, get_simple_organization } from "@/api/common.js";
import { getDisClostDetail } from "@/api/internetSales/projectClarifi.js";
export default {
  components: {//启动组件
    ProduceCoordinate: produceCoordinate,
  },
  mixins: [mixin],
  data() {
    return {
      engineeringIdList: [],
      /*表格增删改查及下载接口*/
      queryPage: queryPage,
      DownloadURL: Download,
      pagesType: 0,
      /*表格数据*/
      table: [
        { label: "订单编号", width: "auto", prop: "orderNo", status: true },
        { label: "工程名称", width: "160", prop: "engineeringName", status: true },
        { label: "工程地址", width: "auto", prop: "place", status: true },
        { label: "浇筑部位", width: "120", prop: "structuralParts", status: true },
        { label: "产品名", width: "160", prop: "productName", status: true },
        { label: "配合比", width: "80", prop: "", status: true },
        { label: "交工配合比编号", width: "120", prop: "mixRatioNumber", status: true },
        { label: "报告时间", width: "135", prop: "reportTime", status: true },
        { label: "浇筑时间", width: "135", prop: "pouringTime", status: true },
        { label: "类型", width: "120", prop: "", status: true },
        { label: "操作", width: "120", prop: "", status: true },
      ],
      tableDataSelect: [],
      addDialog: false,
      look1Name: '',
      formData: {
        stationId: '',
        structuralParts: '',
        contractId: '',
        engineeringId: "",
        strengthGradeId: "", //强度等级
        performanceGradeId: "", //性能等级
        meterialRequirementsId: "", //材料要求
        specialRequirementsId: "", //特殊要求
        otherRequirementsId: "", //其他要求list
        admixtureRequirements: "", //外加剂要求
        pouringMethod: "", //浇筑方式
        pouringTime: "", //浇筑时间
        pouringNum: '',
        pouringHigh: '',
        person: '',
        phoneNum: '',
        remark: '',
      },
      rules: {
        structuralParts: [
          {
            required: true,
            message: "请输入浇筑部位",
            trigger: "change",
          },
        ],
        strengthGradeId: [
          {
            required: true,
            message: "请选择强度等级",
            trigger: "change",
          },
        ],
        performanceGradeId: [
          {
            required: true,
            message: "请选择性能等级",
            trigger: "change",
          },
        ],
        meterialRequirementsId: [
          {
            required: true,
            message: "请选择材料要求",
            trigger: "change",
          },
        ],
        specialRequirementsId: [
          {
            required: true,
            message: "请选择特殊要求",
            trigger: "change",
          },
        ],
        otherRequirementsId: [
          {
            required: true,
            message: "请选择其他要求",
            trigger: "change",
          },
        ],
        admixtureRequirements: [
          {
            required: true,
            message: "请选择外加剂要求",
            trigger: "change",
          },
        ],
        pouringMethod: [
          {
            required: true,
            message: "请选择浇筑方式",
            trigger: "change",
          },
        ],
        pouringTime: [
          {
            required: true,
            message: "请选择浇筑时间",
            trigger: "change",
          },
        ],
        pouringNum: [
          {
            required: true,
            message: "请输入浇筑用量",
            trigger: "change",
          },
        ],
        pouringHigh: [
          {
            required: true,
            message: "请输入泵送高度",
            trigger: "change",
          },
        ],
        person: [
          {
            required: true,
            message: "请输入联系人",
            trigger: "change",
          },
        ],
        phoneNum: [
          {
            required: true,
            message: "请输入联系电话",
            trigger: "change",
          },
          { min: 11, max: 11, message: "手机号格式错误", trigger: "change" },
        ],
      },
      stationIdlist: [],//当前工程公司的所有站点
      strengthGradeList: [], //强度list
      performanceGradeList: [], //性能等级list
      meterialRequirementsList: [], //材料要求list
      specialRequirementsList: [], //特殊要求list
      otherRequirementsList: [], //其他要求list
      admixtureRequirementsList: [], //外加剂要求list
      pouringMethodList: [], //浇筑方式list
      structuralPartsList: [], //浇筑部位
      planQuerySignOfPageData: {//客户订单列表查询
        page: 1,
        pageSize: 10,
        total: 0,
        engineeringId: ''
      },
      look2Type: false,
      QuerySignOfPageArr: [],////客户订单列表
      handOverPlans: [],//客户订单选中项
      look4Type: false,
      look4Data: [],
      look5Type: false,
      look5Data: [],
    };
  },
  async created() {
    const { query } = this.$route;
    this.tableParam.handOverDataId = query.handOverDataId
    this.tableParam.engineeringId = query.engineeringId
    this.planQuerySignOfPageData.engineeringId = query.engineeringId
    this.tableParam.engineeringName = query.engineeringName
    this.tableParam.place = query.place
    this.gettableData();
    this.UserInfo = await getUserInfo();
    getStationByCompanyId({ id: this.UserInfo.companyId }).then((res) => {
      this.stationIdlist = res.data.map((v) => {
        return {
          id: v.stationId,
          name: v.stationName
        }
      })
    });
  },
  methods: {
    /**修改抗压报告值 */
    submit5Fun() {
      update_strength_assessment(this.look5Data).then((res) => {
        if (res.code == 1001) {
          this.look5Type = false
          this.$message({
            type: 'success',
            message: '修改成功!'
          });
        }
      })
    },
    /** 编辑抗压报告值*/
    look5Fun(list, centralValue) {
      this.look5Type = true
      this.look5Data = list
      this.look5Data[0].centralValue = centralValue
    },
    /** 强度合格评定*/
    look4Fun() {
      this.look4Type = true
      handOverPlanstrength_assessment({ handOverDataId: this.tableParam.handOverDataId }).then((res) => {
        this.look4Data = res.data
      })
    },
    handOverPlandeleteResordFun() {
      ('此操作删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let arr = this.tableDataSelect.map((res) => res.id)
        handOverPlandeleteResord(arr).then((res) => {
          if (res.code == 1001) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
            this.gettableData();
          }
        })
      })
    },
    /**添加客户订单 */
    handOverPlansaveClientOrderFun() {
      let json = {
        handOverDataId: this.tableParam.handOverDataId,
        handOverPlans: this.handOverPlans
      }
      handOverPlansaveClientOrder(json).then((res) => {
        if (res.code == 1001) {
          this.$message({
            message: "添加成功",
            type: "success",
          });
          this.look2Type = false
          this.gettableData()
        }
      })
    },
    selectionChange2(val) {
      this.handOverPlans = val
    },
    /**客户订单列表 */
    planQuerySignOfPageFun() {
      this.look2Type = true
      planQuerySignOfPage(this.planQuerySignOfPageData).then((res) => {
        this.QuerySignOfPageArr = res.data.data
        this.planQuerySignOfPageData.total = res.data.totalRows
      })
    },
    //添加交工订单
    submit() {
      this.$refs.reffromData.validate((valid) => {
        if (valid) {
          this.formData.strengthGrade = this.$fromatTable(
            this.strengthGradeList,
            this.formData.strengthGradeId,
            "ID",
            "NAME"
          );
          //性能等级-开始数据重装
          if (this.formData.performanceGradeId.length > 0) {
            let arr = [];
            this.formData.performanceGradeId.forEach((v) => {
              this.performanceGradeList.forEach((v2) => {
                if (v == v2.id) {
                  arr.push({
                    id: v,
                    name: v2.name,
                  });
                }
              });
            });
            this.formData.performanceGrade = JSON.stringify(arr);
          }
          //材料要求-开始数据重装
          if (this.formData.meterialRequirementsId.length > 0) {
            let arr = [];
            this.formData.meterialRequirementsId.forEach((v) => {
              this.meterialRequirementsList.forEach((v2) => {
                if (v == v2.id) {
                  arr.push({
                    id: v,
                    name: v2.name,
                  });
                }
              });
            });
            this.formData.meterialRequirements = JSON.stringify(arr);
          }
          //特殊要求-开始数据重装
          if (this.formData.specialRequirementsId.length > 0) {
            let arr = [];
            this.formData.specialRequirementsId.forEach((v) => {
              this.specialRequirementsList.forEach((v2) => {
                if (v == v2.id) {
                  arr.push({
                    id: v,
                    name: v2.name,
                  });
                }
              });
            });
            this.formData.specialRequirements = JSON.stringify(arr);
          }
          //其他要求-开始数据重装
          if (this.formData.otherRequirementsId.length > 0) {
            let arr = [];
            this.formData.otherRequirementsId.forEach((v) => {
              this.otherRequirementsList.forEach((v2) => {
                if (v == v2.id) {
                  arr.push({
                    id: v,
                    name: v2.name,
                  });
                }
              });
            });
            this.formData.otherRequirements = JSON.stringify(arr);
          }
          //外加剂要求-开始数据重装
          if (this.formData.admixtureRequirements.length > 0) {
            let arr = [];
            this.formData.admixtureRequirements.forEach((v) => {
              this.admixtureRequirementsList.forEach((v2) => {
                if (v == v2.id) {
                  arr.push({
                    id: v,
                    name: v2.name,
                  });
                }
              });
            });
            this.formData.admixtureRequirements = JSON.stringify(arr);
          }
          //浇筑方式-开始数据重装
          if (this.formData.pouringMethod.length > 0) {
            let arr = [];
            this.formData.pouringMethod.forEach((v) => {
              this.pouringMethodList.forEach((v2) => {
                if (v == v2.id) {
                  arr.push({
                    id: v,
                    name: v2.itemName,
                  });
                }
              });
            });
            this.formData.pouringMethod = arr;
            this.formData.pouringMethod = JSON.stringify(this.formData.pouringMethod);
          }
          this.formData.approvalStatus = 2;
          this.formData.handOverDataId = this.tableParam.handOverDataId
          this.structuralPartsFun()
          console.log(JSON.parse(JSON.stringify(this.formData)))
          handOverPlansaveOrUpdate(this.formData).then((res) => {
            if (res.code == 1001) {
              this.addDialog = false;
              this.$message({
                message: "添加成功",
                type: "success",
              });
              this.gettableData();
            }
          });
        } else {
          return false;
        }
      });
    },
    /**浇筑部位校验是输入还是选择 */
    structuralPartsFun() {
      let item = this.structuralPartsList.find((v) => v.id == this.formData.structuralParts)
      if (item) {
        this.formData.structuralPartsId = this.formData.structuralParts
        this.formData.structuralParts = item.structuralParts
      } else {
        this.formData.structuralPartsId = ''
      }
    },
    /**通过站点查询公司 */
    get_simple_organizationFun(id) {
      get_simple_organization({ id: id }).then((res) => {
        this.formData.companyId = res.data.id
        this.formData.company = res.data.name
      });//查询站点所属公司
    },
    /**浇筑部位选择后 */
    structuralPartsCheckFun() {
      this.formData.strengthGradeId = ''
      this.formData.performanceGradeId = ''
      this.formData.meterialRequirementsId = ''
      this.formData.specialRequirementsId = ''
      this.formData.otherRequirementsId = ''
      this.formData.admixtureRequirements = ''
      console.log(JSON.parse(JSON.stringify(this.structuralPartsList)))
      let item = this.structuralPartsList.find((v) => v.id == this.formData.structuralParts)
      if (item) {
        this.formData.strengthGradeId = JSON.parse(item.strengthGrade)[0].id
        if (item.performanceGrade) {
          this.formData.performanceGradeId = JSON.parse(item.performanceGrade).map((v) => v.id)
        }
        if (item.meterialRequirements) {
          this.formData.meterialRequirementsId = JSON.parse(item.meterialRequirements).map((v) => v.id)
        }
        if (item.specialRequirements) {
          this.formData.specialRequirementsId = JSON.parse(item.specialRequirements).map((v) => v.id)
        }
        if (item.otherRequirements) {
          this.formData.otherRequirementsId = JSON.parse(item.otherRequirements).map((v) => v.id)
        }
        if (item.admixtureRequirements) {
          this.formData.admixtureRequirements = JSON.parse(item.admixtureRequirements).map((v) => v.id)
        }
      }
    },
    /**工程选择后查询浇筑部位 */
    addDialogFun(name, row) {
      this.look1Name = name
      this.addDialog = true
      this.$nextTick(() => {
        this.$refs.reffromData.resetFields()
        if (row) {
          this.formData = row
          graphic_list({ engineeringId: this.formData.engineeringId }).then((res) => {
            this.structuralPartsList = res.data;
          });
          this.getDisClostDisAddCostFun(this.formData.engineeringId)
          this.formData.performanceGradeId = JSON.parse(this.formData.performanceGrade).map((v) => v.id)
          this.formData.meterialRequirementsId = JSON.parse(this.formData.meterialRequirements).map((v) => v.id)
          this.formData.specialRequirementsId = JSON.parse(this.formData.specialRequirements).map((v) => v.id)
          this.formData.otherRequirementsId = JSON.parse(this.formData.otherRequirements).map((v) => v.id)
          this.formData.admixtureRequirements = JSON.parse(this.formData.admixtureRequirements).map((v) => v.id)
          this.formData.pouringMethod = JSON.parse(this.formData.pouringMethod).map((v) => v.id)
        } else {
          this.formData.engineeringId = this.tableParam.engineeringId
          this.formData.engineeringName = this.tableParam.engineeringName
          this.formData.place = this.tableParam.place
          let day3 = new Date();
          day3.setTime(day3.getTime() + 24 * 60 * 60 * 1000);
          var s3 = day3.getFullYear() + "-" + (day3.getMonth() + 1) + "-" + day3.getDate();
          this.formData.pouringTime = new Date(s3).Format('yyyy-MM-dd') + ' 08:00:00'
          graphic_list({ engineeringId: this.formData.engineeringId }).then((res) => {
            this.structuralPartsList = res.data;
          });
          this.getDisClostDisAddCostFun(this.formData.engineeringId)
        }
      });
    },
    list1SelectionFun(val) {
      this.tableDataSelect = val;
    },
    /*重置数据*/
    init() {
      this.tableParam.structuralParts = "";
      this.gettableData();
    },
    /**查询该工程的强度等级+各项要求+浇筑部位 */
    getDisClostDisAddCostFun(id) {
      getDisClostDetail({ id }).then(res => {
        if (res.code === 1001) {
          this.strengthGradeList = JSON.parse(res.data.strengthGrade);
          this.performanceGradeList = JSON.parse(res.data.performanceRate);
          //材料要求pouringMethodList
          this.meterialRequirementsList = JSON.parse(res.data.materialRequirements);
          //特殊要求
          this.specialRequirementsList = JSON.parse(res.data.specialRequirements);
          //外加剂要求
          this.admixtureRequirementsList = JSON.parse(res.data.admixtureRequirements);
          //其他要求
          this.otherRequirementsList = JSON.parse(res.data.otherRequirements);
          //浇筑方式
          this.pouringMethodList = JSON.parse(res.data.pumpType);
        }
      })
    },
  },
};
</script>

<style lang="scss" scoped>
.dialogOtherinfo {
  .el-pagination {
    padding: 10px 0;
  }
  .form-title {
    font-size: 18px;
    margin: 10px 0;
  }
}
.el-input,
.el-select {
  width: 240px;
}
/*
 <el-link class="table_link" :underline="false">查看配合比</el-link>*/
.table_link {
  margin: 0 10px;
  color: $bg_color;
  cursor: pointer;
}

.table_link:hover {
  opacity: 0.8;
}
.dataPlan {
  .FzyBox {
    background: #f2f2f2;
    border-radius: 5px;
    > div {
      display: flex;
      margin-bottom: 10px;
      > div:nth-of-type(1) {
        flex: none;
        width: 160px;
        text-align: right;
      }
      span {
        padding: 10px;
        display: inline-block;
        margin-right: 50px;
      }
    }
  }
  .FzyBox2 {
    display: flex;
    > div:nth-of-type(1) {
      width: 120px;
      text-align: right;
      > div {
        height: 40px;
        line-height: 40px;
      }
    }
    > div:nth-of-type(2) {
      flex: 1;
      display: flex;
      .box1 {
        flex: none;
        width: 130px;
        line-height: 40px;
        padding: 0px 5px;
        > div {
          height: 40px;
        }
      }
    }
  }
}
</style>